package com.srxz.mobilepharmacy.controller;

import com.srxz.mobilepharmacy.entity.ClinicRecPK;
import com.srxz.mobilepharmacy.service.ClinicRecService;
import com.srxz.mobilepharmacy.util.back.BackMessage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpSession;
import java.math.BigInteger;
import java.text.ParseException;
import java.util.List;

@RestController
@RequestMapping("/mph/rec")
public class ClinicRecController {
    @Autowired
    private ClinicRecService clinicRecService;

    @GetMapping("/all")
    public BackMessage findAllRec(BigInteger aid, Boolean now, String search, HttpSession session) throws ParseException {
        return clinicRecService.findAllRec(aid, now, search, session);
    }

    @GetMapping("/one")
    public BackMessage findRec(BigInteger aid, BigInteger patid, BigInteger sn) throws ParseException {
        return clinicRecService.findRec(aid, patid, sn);
    }

    @PostMapping("/dispensing")
    public BackMessage dispensing(@RequestBody List<ClinicRecPK> clinicRecPKs, HttpSession session){
        return clinicRecService.dispensing(clinicRecPKs, session);
    }
}
